Skip to content

chore(FR-831): update ResourcePresetSettingModal to display exact memory value#3540

Merged
graphite-app[bot] merged 1 commit into
mainfrom
chore/display-exact-memory-value
May 28, 2025
Merged

chore(FR-831): update ResourcePresetSettingModal to display exact memory value#3540
graphite-app[bot] merged 1 commit into
mainfrom
chore/display-exact-memory-value

Conversation

@nowgnuesLee
Copy link
Copy Markdown
Contributor

@nowgnuesLee nowgnuesLee commented Apr 19, 2025

resolves #3498 (FR-831)

changes

  • Changed convertBinarySizeUnit() for memory values to initialize to the correct exact via auto when using convertBinarySizeUnit().
  • Changed ResourcePresetList to more accurately show the value for shared memory.
  • add sizeUnitToDecimalSizeUnit and sizeUnitToBinarySizeUnit function.
  • Fixed strange unit display in modal when memory value was set to 0
  • add NumberWithUnit component

CleanShot 2025-04-22 at 10.49.27@2x.png

0726e961-e285-4594-a06b-bd2edcadc425.jpg

Checklist: (if applicable)

  • Documentation
  • Minium required manager version
  • Specific setting for review (eg., KB link, endpoint or how to setup)
  • Minimum requirements to check during review
  • Test case(s) to demonstrate the difference of before/after

Copy link
Copy Markdown
Contributor Author

nowgnuesLee commented Apr 19, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 19, 2025

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements 4.62% 481/10415
🔴 Branches 4.04% 297/7350
🔴 Functions 2.74% 90/3288
🔴 Lines 4.57% 466/10195

Test suite run success

161 tests passing in 15 suites.

Report generated by 🧪jest coverage report action from fb95980

@nowgnuesLee nowgnuesLee marked this pull request as ready for review April 19, 2025 12:58
Copy link
Copy Markdown
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same problem with shared memory, please fix it as well.

@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch from 7c66f49 to 4ed41d0 Compare April 22, 2025 01:49
@nowgnuesLee nowgnuesLee requested a review from ironAiken2 April 22, 2025 01:52
Copy link
Copy Markdown
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread react/src/components/ResourcePresetList.tsx Outdated
@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch from 4ed41d0 to eb9ece5 Compare April 22, 2025 04:34
@nowgnuesLee nowgnuesLee requested a review from agatha197 April 22, 2025 04:34
@github-actions github-actions Bot added size:S 10~30 LoC and removed size:XS ~10 LoC labels Apr 22, 2025
Comment thread react/src/components/ResourceNumber.tsx Outdated
Comment thread react/src/components/ResourceNumber.tsx
@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch 2 times, most recently from 3946b5e to f05487e Compare April 25, 2025 09:33
@github-actions github-actions Bot added area:ux UI / UX issue. area:i18n Localization size:L 100~500 LoC and removed size:S 10~30 LoC labels Apr 25, 2025
@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch from f05487e to 7b08859 Compare April 28, 2025 04:08
@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch from 7b08859 to dcd659f Compare April 29, 2025 07:26
@nowgnuesLee nowgnuesLee requested a review from Copilot May 20, 2025 01:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refines how memory values are displayed by removing hardcoded “(GB)” labels, introducing new unit-conversion helpers, and updating UI components to show exact or fallback values, especially handling zero correctly.

  • Removed “(GB)” suffix from SharedMemory labels across all locales
  • Added sizeUnitToDecimalSizeUnit and sizeUnitToBinarySizeUnit helper functions
  • Updated ResourcePresetSettingModal, ResourcePresetList, and ResourceNumber to use auto-scaling conversions and handle zero memory values properly

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
resources/i18n/*.json Removed the hardcoded “(GB)” suffix from SharedMemory translations
react/src/helper/index.tsx Added DecimalSizeUnit/BinarySizeUnit types and mapping functions sizeUnitToDecimalSizeUnit & sizeUnitToBinarySizeUnit
react/src/components/ResourcePresetSettingModal.tsx Switched memory conversion to use 'auto' when value ≠ 0 and fixed zero display
react/src/components/ResourcePresetList.tsx Enhanced shared-memory column to show primary and fallback unit formats
react/src/components/ResourceNumber.tsx Added secondary fallback display for non-zero memory with auto conversion
Comments suppressed due to low confidence (1)

react/src/helper/index.tsx:188

  • There are no unit tests covering sizeUnitToDecimalSizeUnit and sizeUnitToBinarySizeUnit. Adding tests will ensure correct mappings and prevent regressions.
return unitMap[unit] || unit;

Comment thread react/src/components/ResourceNumber.tsx Outdated
Comment thread react/src/components/ResourcePresetList.tsx Outdated
Comment thread react/src/components/ResourcePresetSettingModal.tsx
Comment thread react/src/components/ResourceNumber.tsx Outdated
@nowgnuesLee nowgnuesLee force-pushed the chore/display-exact-memory-value branch 4 times, most recently from 8c77c5d to 2026ac0 Compare May 23, 2025 07:03
@nowgnuesLee nowgnuesLee requested a review from yomybaby May 23, 2025 07:07
Copy link
Copy Markdown
Contributor

@agatha197 agatha197 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nowgnuesLee nowgnuesLee requested a review from lizable May 28, 2025 07:39
Copy link
Copy Markdown
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be Okay to display 4 MiB instead of 0 GiB(4 MiB)?

Copy link
Copy Markdown
Contributor

@lizable lizable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Copy Markdown
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I made a refactoring PR for this PR changes.

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 28, 2025

Merge activity

…ory value (#3540)

resolves #3498 (FR-831)

**changes**
* Changed `convertBinarySizeUnit()` for memory values to initialize to the correct exact via `auto` when using `convertBinarySizeUnit()`.
* Changed `ResourcePresetList` to more accurately show the value for `shared memory`.
* add `sizeUnitToDecimalSizeUnit` and `sizeUnitToBinarySizeUnit` function.
* Fixed strange unit display in modal when memory value was set to 0
* add `NumberWithUnit` component

![CleanShot 2025-04-22 at 10.49.27@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/xbCemO1RqqcSjEXCRK3p/55a62c67-8a20-4f07-9377-1b7c1fa475ca.png)

![0726e961-e285-4594-a06b-bd2edcadc425.jpg](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/xbCemO1RqqcSjEXCRK3p/74e294b1-169e-4b07-be48-ff9f149028b4.jpg)

**Checklist:** (if applicable)

- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
@graphite-app graphite-app Bot force-pushed the chore/display-exact-memory-value branch from f9dac72 to fb95980 Compare May 28, 2025 23:36
@graphite-app graphite-app Bot merged commit fb95980 into main May 28, 2025
8 checks passed
@graphite-app graphite-app Bot deleted the chore/display-exact-memory-value branch May 28, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n Localization area:ux UI / UX issue. size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change resource preset settings modal to dynamically modify resource units

6 participants